<#if poll?exists>
    <#assign pollQuestion = poll.label?default("")?html/>
    <#assign pollLength = poll.length/>
    <#else>
        <#assign pollQuestion = ""/>
        <#assign pollLength = "0"/>
</#if>
<div class="genmed"><b>${I18n.getMessage("PostForm.pollQuestion")}</b>
    <input type="text" name="poll_label" maxlength="255" size="50" value="${pollQuestion}"></input>
</div>
<div class="genmed" id="pollOptionWithDelete" style="display: none;">
    ${I18n.getMessage("PostForm.pollOption")}
    <input type="text" id="pollOption" name="poll_option" maxlength="255" size="50"></input>
    <input type="button" onclick="javascript:deletePollOption(this)"
           value="${I18n.getMessage("PostForm.pollDeleteOption")}"></input>
</div>
<#if poll?exists>
    <#assign optionCount = 0/>
    <#list poll.options as option>
        <#assign optionText = option.text?default("")?html/>
        <div class="genmed" id="pollOption">
            ${I18n.getMessage("PostForm.pollOption")}
            <input type="text" id="pollOption${option.id}"
                   name="poll_option_${option.id}" maxlength="255" size="50"
                   value="${optionText}"></input>
            <input type="button" onclick="javascript:deletePollOption(this)"
                   value="${I18n.getMessage("PostForm.pollDeleteOption")}"></input>
        </div>
        <#if (option.id > optionCount)>
            <#assign optionCount = option.id/>
        </#if>
    </#list>
    <input type="hidden" name="poll_option_count" id="pollOptionCount" value="${optionCount}"/>
    <#else>
        <input type="hidden" name="poll_option_count" id="pollOptionCount" value="1"/>
        <div class="genmed" id="pollOption">
            ${I18n.getMessage("PostForm.pollOption")}
            <input type="text" id="pollOption1" name="poll_option_1" maxlength="255" size="50"></input>
            <input type="button" onclick="javascript:deletePollOption(this)"
                   value="${I18n.getMessage("PostForm.pollDeleteOption")}"></input>
        </div>
</#if> 
<div class="genmed" id="pollOptionWithAdd">
    ${I18n.getMessage("PostForm.pollAddOption")}
    <input type="button" onclick="javascript:addPollOption()"
           value="${I18n.getMessage("PostForm.pollAddOption")}"></input>
</div>
<div class="genmed">
    ${I18n.getMessage("PostForm.pollRunFor")}
    <input type="text" name="poll_length" maxlength="5" size="4" value="${pollLength}"></input>
    ${I18n.getMessage("PostForm.pollDays")}
    <span class="gensmall">${I18n.getMessage("PostForm.pollDaysDescription")}</span>
</div>